
package handling.channel.handler;


import client.*;
import client.inventory.*;
import client.skills.Skill;
import client.skills.SkillFactory;
import configs.NebuliteConfig;
import configs.ServerConfig;
import constants.*;
import handling.world.WorldBroadcastService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.*;
import server.cashshop.CashItemFactory;
import server.life.MapleLifeFactory;
import server.maps.*;
import server.quest.MapleQuest;
import server.shop.MapleShopFactory;
import server.shops.HiredMerchant;
import tools.DateUtil;
import tools.MaplePacketCreator;
import tools.Pair;
import tools.Randomizer;
import tools.data.input.LittleEndianAccessor;
import tools.packet.EffectPacket;
import tools.packet.InventoryPacket;
import tools.packet.MTSCSPacket;
import tools.packet.PetPacket;

import java.awt.*;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
















































 public class UseCashItemHandler {
    /*   51 */   private static final Logger log = LogManager.getLogger();

    public static void handlePacket(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) throws SQLException {
        int skill1;
        MapleLove love;
        String sendTo, msg;
        int uniqueid, itemSearch;
        MaplePet pet;
        Rectangle bounds;
        String name;
        Equip item;
        String nName;
        int rewardItemId, skill2;
        String str1, ourMsg;
        MaplePet maplePet1;
        List<HiredMerchant> hms;
        MaplePet[] pets;
        MapleMist mist;
        String otherName;
        int needItemId;
        Skill skillSPTo;
        int buff;
        String str2;
        int i;
        byte petIndex;
        int[] needItemIds;
        Skill skillSPFrom;
        PredictCardFactory pcf;
        int randItemId;
        List<Integer> arrayList;
        PredictCardFactory.PredictCard Card;

        int j, commentId;

        PredictCardFactory.PredictCardComment Comment;
        /*   54 */
        if (chr == null || chr.getMap() == null || chr.inPVP()) {
            /*   55 */
            c.announce(MaplePacketCreator.enableActions());

            return;

        }
        /*   58 */
        chr.updateTick(slea.readInt());
        /*   59 */
        chr.setScrolledPosition((short) 0);
        /*   60 */
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        /*   61 */
        short slot = slea.readShort();
        /*   62 */
        int itemId = slea.readInt();
        /*   63 */
        int itemType = itemId / 10000;
        /*   64 */
        Item toUse = chr.getInventory(MapleInventoryType.CASH).getItem(slot);
        /*   65 */
        if (toUse == null || toUse.getItemId() != itemId || toUse.getQuantity() < 1 || chr.hasBlockedInventory()) {
            /*   66 */
            c.announce(MaplePacketCreator.enableActions());

            return;

        }
        /*   69 */
        if (chr.isAdmin()) {
            /*   70 */
            chr.dropMessage(5, "使用商城道具 物品ID: " + itemId + " 物品类型: " + itemType);

        }
        /*   72 */
        boolean used = false, cc = false;
        /*   73 */
        switch (itemType) {

            case 504:
                /*   75 */
                if (itemId == 5043000 || itemId == 5043001) {
                    /*   76 */
                    short questid = slea.readShort();
                    /*   77 */
                    int npcid = slea.readInt();
                    /*   78 */
                    MapleQuest quest = MapleQuest.getInstance(questid);
                    /*   79 */
                    if (chr.getQuest(quest).getStatus() == 1 && quest.canComplete(chr, Integer.valueOf(npcid))) {
                        /*   80 */
                        int mapId = MapleLifeFactory.getNPCLocation(npcid);
                        /*   81 */
                        if (mapId != -1) {
                            /*   82 */
                            MapleMap map = c.getChannelServer().getMapFactory().getMap(mapId);
                            /*   83 */
                            if (map.containsNPC(npcid) && !FieldLimitType.VipRock.check(chr.getMap().getFieldLimit()) && !FieldLimitType.VipRock.check(map.getFieldLimit()) && !chr.isInBlockedMap()) {
                                /*   84 */
                                chr.changeMap(map, map.getPortal(0));

                            }
                            /*   86 */
                            used = true;
                            break;

                        }
                        /*   88 */
                        chr.dropMessage(1, "使用道具出现未知的错误.");

                    }
                    break;

                }
                /*   91 */
                if (itemId == 5042000) {
                    /*   92 */
                    MapleMap map = c.getChannelServer().getMapFactory().getMap(701000200);
                    /*   93 */
                    chr.changeMap(map, map.getPortal(0));
                    /*   94 */
                    used = true;
                    break;

                }
                /*   96 */
                if (itemId == 5040005) {
                    /*   97 */
                    chr.dropMessage(5, "无法使用这个道具.");
                    break;

                }
                /*   99 */
                if (itemId == 5044011) {
                    /*  100 */
                    slea.skip(1);
                    /*  101 */
                    MapleMap map = c.getChannelServer().getMapFactory().getMap(slea.readInt());
                    /*  102 */
                    chr.changeMap(map, map.getPortal(0));

                    break;

                }
                /*  105 */
                used = InventoryHandler.UseTeleRock(slea, c, itemId);

                break;



            case 505:
                /*  110 */
                if (itemId == 5050000) {
                    /*  111 */
                    List<Pair<MapleStat, Long>> statupdate = new ArrayList<>(2);
                    /*  112 */
                    int apto = (int) slea.readLong();
                    /*  113 */
                    int apfrom = (int) slea.readLong();
                    /*  114 */
                    int statLimit = ServerConfig.CHANNEL_PLAYER_MAXAP;
                    /*  115 */
                    if (chr.isAdmin()) {
                        /*  116 */
                        chr.dropMessage(5, "洗能力点 apto: " + apto + " apfrom: " + apfrom);

                    }
                    /*  118 */
                    if (apto == apfrom) {

                        break;

                    }
                    /*  121 */
                    int job = chr.getJob();
                    /*  122 */
                    PlayerStats playerst = chr.getStat();
                    /*  123 */
                    used = true;
                    /*  124 */
                    switch (apto) {

                        case 64:
                            /*  126 */
                            if (playerst.getStr() >= statLimit) {
                                /*  127 */
                                used = false;

                            }

                            break;

                        case 128:
                            /*  131 */
                            if (playerst.getDex() >= statLimit) {
                                /*  132 */
                                used = false;

                            }

                            break;

                        case 256:
                            /*  136 */
                            if (playerst.getInt() >= statLimit) {
                                /*  137 */
                                used = false;

                            }

                            break;

                        case 512:
                            /*  141 */
                            if (playerst.getLuk() >= statLimit) {
                                /*  142 */
                                used = false;

                            }

                            break;

                        case 2048:
                            /*  146 */
                            if (playerst.getMaxHp() >= chr.getMaxHpForSever()) {
                                /*  147 */
                                used = false;

                            }

                            break;

                        case 8192:
                            /*  151 */
                            if (playerst.getMaxMp() >= chr.getMaxMpForSever()) {
                                /*  152 */
                                used = false;

                            }

                            break;

                    }
                    /*  156 */
                    switch (apfrom) {

                        case 64:
                            /*  158 */
                            if (playerst.getStr() <= 4) {
                                /*  159 */
                                used = false;

                            }

                            break;

                        case 128:
                            /*  163 */
                            if (playerst.getDex() <= 4) {
                                /*  164 */
                                used = false;

                            }

                            break;

                        case 256:
                            /*  168 */
                            if (playerst.getInt() <= 4) {
                                /*  169 */
                                used = false;

                            }

                            break;

                        case 512:
                            /*  173 */
                            if (playerst.getLuk() <= 4) {
                                /*  174 */
                                used = false;

                            }

                            break;

                        case 2048:
                            /*  178 */
                            if (chr.getHpApUsed() <= 0 || chr.getHpApUsed() >= 10000) {
                                /*  179 */
                                used = false;

                            }

                            break;

                        case 8192:
                            /*  183 */
                            if (chr.getHpApUsed() <= 0 || chr.getHpApUsed() >= 10000 || JobConstants.isNotMpJob(job)) {
                                /*  184 */
                                used = false;

                            }

                            break;

                    }
                    /*  188 */
                    if (used) {
                        /*  189 */
                        long l1;
                        int k;
                        long toSet;
                        int maxhp, maxmp;
                        switch (apto) {

                            case 64:
                                /*  191 */
                                l1 = (playerst.getStr() + 1);
                                /*  192 */
                                playerst.setStr((short) (int) l1, chr);
                                /*  193 */
                                statupdate.add(new Pair(MapleStat.力量, Long.valueOf(l1)));

                                break;


                            case 128:
                                /*  197 */
                                l1 = (playerst.getDex() + 1);
                                /*  198 */
                                playerst.setDex((short) (int) l1, chr);
                                /*  199 */
                                statupdate.add(new Pair(MapleStat.敏捷, Long.valueOf(l1)));

                                break;


                            case 256:
                                /*  203 */
                                l1 = (playerst.getInt() + 1);
                                /*  204 */
                                playerst.setInt((short) (int) l1, chr);
                                /*  205 */
                                statupdate.add(new Pair(MapleStat.智力, Long.valueOf(l1)));

                                break;


                            case 512:
                                /*  209 */
                                l1 = (playerst.getLuk() + 1);
                                /*  210 */
                                playerst.setLuk((short) (int) l1, chr);
                                /*  211 */
                                statupdate.add(new Pair(MapleStat.运气, Long.valueOf(l1)));

                                break;


                            case 2048:
                                /*  215 */
                                k = playerst.getMaxHp();
                                /*  216 */
                                if (JobConstants.is新手职业(job)) {
                                    /*  217 */
                                    k += Randomizer.rand(4, 8);
                                    /*  218 */
                                } else if (JobConstants.is恶魔复仇者(job)) {
                                    /*  219 */
                                    k += 30;
                                    /*  220 */
                                } else if ((job >= 100 && job <= 132) || (job >= 3200 && job <= 3212) || (job >= 1100 && job <= 1112) || (job >= 3100 && job <= 3112) || (job >= 5100 && job <= 5112)) {
                                    /*  221 */
                                    k += Randomizer.rand(36, 42);
                                    /*  222 */
                                } else if ((job >= 200 && job <= 232) || JobConstants.is龙神(job) || (job >= 1200 && job <= 1212) || (job >= 2700 && job <= 2712)) {
                                    /*  223 */
                                    k += Randomizer.rand(10, 12);
                                    /*  224 */
                                } else if ((job >= 300 && job <= 322) || (job >= 400 && job <= 434) || (job >= 1300 && job <= 1312) || (job >= 1400 && job <= 1412) || (job >= 3300 && job <= 3312) || (job >= 2300 && job <= 2312) || (job >= 2400 && job <= 2412)) {
                                    /*  225 */
                                    k += Randomizer.rand(14, 18);
                                    /*  226 */
                                } else if ((job >= 510 && job <= 512) || (job >= 580 && job <= 582) || (job >= 1510 && job <= 1512)) {
                                    /*  227 */
                                    k += Randomizer.rand(24, 28);
                                    /*  228 */
                                } else if ((job >= 500 && job <= 532) || (job >= 590 && job <= 592) || JobConstants.is龙的传人(job) || (job >= 3500 && job <= 3512) || job == 1500) {
                                    /*  229 */
                                    k += Randomizer.rand(16, 20);
                                    /*  230 */
                                } else if (job >= 2000 && job <= 2112) {
                                    /*  231 */
                                    k += Randomizer.rand(34, 38);

                                } else {
                                    /*  233 */
                                    k += Randomizer.rand(16, 20);

                                }
                                /*  235 */
                                k = Math.min(chr.getMaxHpForSever(), Math.abs(k));
                                /*  236 */
                                chr.setHpApUsed((short) (chr.getHpApUsed() + 1));
                                /*  237 */
                                playerst.setMaxHp(k, chr);
                                /*  238 */
                                statupdate.add(new Pair(MapleStat.MAXHP, Long.valueOf(k)));

                                break;

                            case 8192:
                                /*  241 */
                                maxmp = playerst.getMaxMp();
                                /*  242 */
                                if (JobConstants.is新手职业(job))
                                    /*  243 */ {
                                    maxmp += Randomizer.rand(6, 8);
                                }
                                /*  244 */
                                else {
                                    if (JobConstants.isNotMpJob(job))
                                         return;
                                    /*  246 */
                                    if ((job >= 100 && job <= 132) || (job >= 1100 && job <= 1112) || (job >= 2000 && job <= 2112) || (job >= 5100 && job <= 5112)) {
                                        /*  247 */
                                        maxmp += Randomizer.rand(4, 9);
                                        /*  248 */
                                    } else if ((job >= 200 && job <= 232) || JobConstants.is龙神(job) || (job >= 3200 && job <= 3212) || (job >= 1200 && job <= 1212) || (job >= 2700 && job <= 2712)) {
                                        /*  249 */
                                        maxmp += Randomizer.rand(32, 36);
                                        /*  250 */
                                    } else if ((job >= 300 && job <= 322) || (job >= 400 && job <= 434) || (job >= 500 && job <= 592) || (job >= 3200 && job <= 3212) || (job >= 3500 && job <= 3512) || (job >= 1300 && job <= 1312) || (job >= 1400 && job <= 1412) || (job >= 1500 && job <= 1512) || (job >= 2300 && job <= 2312) || (job >= 2400 && job <= 2412)) {
                                        /*  251 */
                                        maxmp += Randomizer.rand(8, 10);

                                    } else {
                                        /*  253 */
                                        maxmp += Randomizer.rand(6, 8);

                                    }
                                }
                                /*  255 */
                                if (JobConstants.isNotMpJob(job)) {
                                    /*  256 */
                                    chr.dropMessage(1, "该职业无法使用.");
                                    break;

                                }
                                /*  258 */
                                maxmp = Math.min(chr.getMaxMpForSever(), Math.abs(maxmp));
                                /*  259 */
                                chr.setHpApUsed((short) (chr.getHpApUsed() + 1));
                                /*  260 */
                                playerst.setMaxMp(maxmp, chr);
                                /*  261 */
                                statupdate.add(new Pair(MapleStat.MAXMP, Long.valueOf(maxmp)));

                                break;

                        }

                        /*  265 */
                        switch (apfrom) {

                            case 64:
                                /*  267 */
                                toSet = (playerst.getStr() - 1);
                                /*  268 */
                                playerst.setStr((short) (int) toSet, chr);
                                /*  269 */
                                statupdate.add(new Pair(MapleStat.力量, Long.valueOf(toSet)));

                                break;


                            case 128:
                                /*  273 */
                                toSet = (playerst.getDex() - 1);
                                /*  274 */
                                playerst.setDex((short) (int) toSet, chr);
                                /*  275 */
                                statupdate.add(new Pair(MapleStat.敏捷, Long.valueOf(toSet)));

                                break;


                            case 256:
                                /*  279 */
                                toSet = (playerst.getInt() - 1);
                                /*  280 */
                                playerst.setInt((short) (int) toSet, chr);
                                /*  281 */
                                statupdate.add(new Pair(MapleStat.智力, Long.valueOf(toSet)));

                                break;


                            case 512:
                                /*  285 */
                                toSet = (playerst.getLuk() - 1);
                                /*  286 */
                                playerst.setLuk((short) (int) toSet, chr);
                                /*  287 */
                                statupdate.add(new Pair(MapleStat.运气, Long.valueOf(toSet)));

                                break;


                            case 2048:
                                /*  291 */
                                maxhp = playerst.getMaxHp();
                                /*  292 */
                                if (JobConstants.is新手职业(job)) {
                                    /*  293 */
                                    maxhp -= 12;
                                    /*  294 */
                                } else if (JobConstants.is恶魔复仇者(job)) {
                                    /*  295 */
                                    maxhp -= 30;
                                    /*  296 */
                                } else if ((job >= 200 && job <= 232) || (job >= 1200 && job <= 1212) || (job >= 2700 && job <= 2712)) {
                                    /*  297 */
                                    maxhp -= 10;
                                    /*  298 */
                                } else if ((job >= 300 && job <= 322) || (job >= 400 && job <= 434) || (job >= 1300 && job <= 1312) || (job >= 1400 && job <= 1412) || (job >= 3300 && job <= 3312) || (job >= 3500 && job <= 3512) || (job >= 2300 && job <= 2312) || (job >= 2400 && job <= 2412)) {
                                    /*  299 */
                                    maxhp -= 15;
                                    /*  300 */
                                } else if ((job >= 500 && job <= 592) || (job >= 1500 && job <= 1512)) {
                                    /*  301 */
                                    maxhp -= 22;
                                    /*  302 */
                                } else if ((job >= 100 && job <= 132) || (job >= 1100 && job <= 1112) || (job >= 3100 && job <= 3112) || (job >= 5100 && job <= 5112)) {
                                    /*  303 */
                                    maxhp -= 32;
                                    /*  304 */
                                } else if ((job >= 2000 && job <= 2112) || (job >= 3200 && job <= 3212)) {
                                    /*  305 */
                                    maxhp -= 40;

                                } else {
                                    /*  307 */
                                    maxhp -= 20;

                                }
                                /*  309 */
                                chr.setHpApUsed((short) (chr.getHpApUsed() - 1));
                                /*  310 */
                                playerst.setMaxHp(maxhp, chr);
                                /*  311 */
                                statupdate.add(new Pair(MapleStat.MAXHP, Long.valueOf(maxhp)));

                                break;

                            case 8192:
                                /*  314 */
                                maxmp = playerst.getMaxMp();
                                /*  315 */
                                if (JobConstants.is新手职业(job))
                                    /*  316 */ {
                                    maxmp -= 8;
                                }
                                /*  317 */
                                else {
                                    if (JobConstants.isNotMpJob(job))
                                         return;
                                    /*  319 */
                                    if ((job >= 100 && job <= 132) || (job >= 1100 && job <= 1112) || (job >= 5100 && job <= 5112)) {
                                        /*  320 */
                                        maxmp -= 4;
                                        /*  321 */
                                    } else if ((job >= 200 && job <= 232) || (job >= 1200 && job <= 1212) || (job >= 2700 && job <= 2712)) {
                                        /*  322 */
                                        maxmp -= 30;
                                        /*  323 */
                                    } else if ((job >= 500 && job <= 592) || (job >= 300 && job <= 322) || (job >= 400 && job <= 434) || (job >= 1300 && job <= 1312) || (job >= 1400 && job <= 1412) || (job >= 1500 && job <= 1512) || (job >= 3300 && job <= 3312) || (job >= 3500 && job <= 3512) || (job >= 2300 && job <= 2312) || (job >= 2400 && job <= 2412)) {
                                        /*  324 */
                                        maxmp -= 10;
                                        /*  325 */
                                    } else if (job >= 2000 && job <= 2112) {
                                        /*  326 */
                                        maxmp -= 5;

                                    } else {
                                        /*  328 */
                                        maxmp -= 20;

                                    }
                                }
                                /*  330 */
                                if (JobConstants.isNotMpJob(job)) {
                                    /*  331 */
                                    chr.dropMessage(1, "该职业无法使用.");
                                    break;

                                }
                                /*  333 */
                                chr.setHpApUsed((short) (chr.getHpApUsed() - 1));
                                /*  334 */
                                playerst.setMaxMp(maxmp, chr);
                                /*  335 */
                                statupdate.add(new Pair(MapleStat.MAXMP, Long.valueOf(maxmp)));

                                break;

                        }

                        /*  339 */
                        c.announce(MaplePacketCreator.updatePlayerStats(statupdate, true, chr));

                    }
                    break;

                }
                /*  342 */
                if (itemId >= 5050005 && !JobConstants.is龙神(chr.getJob())) {
                    /*  343 */
                    chr.dropMessage(1, "只有龙神职业才能使用这个道具.");

                    break;

                }
                /*  346 */
                if (itemId < 5050005 && JobConstants.is龙神(chr.getJob())) {
                    /*  347 */
                    chr.dropMessage(1, "龙神职业无法使用这个道具.");

                    break;

                }
                /*  350 */
                skill1 = slea.readInt();
                /*  351 */
                skill2 = slea.readInt();
                /*  352 */
                for (int k : GameConstants.blockedSkills) {
                    /*  353 */
                    if (skill1 == k) {
                        /*  354 */
                        chr.dropMessage(1, "该技能未修复，无法增加此技能.");

                        return;

                    }

                }
                /*  358 */
                skillSPTo = SkillFactory.getSkill(skill1);
                /*  359 */
                skillSPFrom = SkillFactory.getSkill(skill2);
                /*  360 */
                if (skillSPTo.isBeginnerSkill() || skillSPFrom.isBeginnerSkill()) {
                    /*  361 */
                    chr.dropMessage(1, "无法对新手技能使用.");

                    break;

                }
                /*  364 */
                if (JobConstants.getSkillBookBySkill(skill1) != JobConstants.getSkillBookBySkill(skill2)) {
                    /*  365 */
                    chr.dropMessage(1, "You may not add different job skills.");

                    break;

                }
                /*  368 */
                if (chr.getSkillLevel(skillSPTo) + 1 <= skillSPTo.getMaxLevel() && chr.getSkillLevel(skillSPFrom) > 0 && skillSPTo.canBeLearnedBy(chr.getJob())) {
                    /*  369 */
                    if (SkillConstants.isFourthJob(skill1) && chr.getSkillLevel(skillSPTo) + 1 > chr.getMasterLevel(skillSPTo)) {
                        /*  370 */
                        chr.dropMessage(1, "You will exceed the master level.");

                        break;

                    }
                    /*  373 */
                    if (itemId >= 5050005) {
                        /*  374 */
                        if (JobConstants.getSkillBookBySkill(skill1) != (itemId - 5050005) * 2 && JobConstants.getSkillBookBySkill(skill1) != (itemId - 5050005) * 2 + 1) {
                            /*  375 */
                            chr.dropMessage(1, "You may not add this job SP using this reset.");

                            break;

                        }

                    } else {
                        /*  379 */
                        int theJob = JobConstants.getJobNumber(skill2 / 10000);
                        /*  380 */
                        switch (skill2 / 10000) {

                            case 430:
                                /*  382 */
                                theJob = 1;

                                break;

                            case 431:

                            case 432:
                                /*  386 */
                                theJob = 2;

                                break;

                            case 433:
                                /*  389 */
                                theJob = 3;

                                break;

                            case 434:
                                /*  392 */
                                theJob = 4;

                                break;

                        }
                        /*  395 */
                        if (theJob != itemId - 5050000) {
                            /*  396 */
                            chr.dropMessage(1, "You may not subtract from this skill. Use the appropriate SP reset.");

                            break;

                        }

                    }
                    /*  400 */
                    chr.changeSingleSkillLevel(skillSPFrom, (byte) (chr.getSkillLevel(skillSPFrom) - 1), chr.getMasterLevel(skillSPFrom));
                    /*  401 */
                    chr.changeSingleSkillLevel(skillSPTo, (byte) (chr.getSkillLevel(skillSPTo) + 1), chr.getMasterLevel(skillSPTo));
                    /*  402 */
                    used = true;

                }

                break;



            case 506:
                /*  408 */
                if (itemId == 5060000) {
                    /*  409 */
                    Item item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(slea.readShort());
                    /*  410 */
                    if (item1 != null && item1.getOwner().equals("")) {
                        /*  411 */
                        boolean change = true;
                        /*  412 */
                        for (String z : GameConstants.RESERVED) {
                            /*  413 */
                            if (chr.getName().contains(z)) {
                                /*  414 */
                                change = false;

                            }

                        }
                        /*  417 */
                        if (change) {
                            /*  418 */
                            item1.setOwner(chr.getName());
                            /*  419 */
                            chr.forceUpdateItem(item1);
                            /*  420 */
                            used = true;

                        }

                        break;

                    }
                    /*  424 */
                    chr.dropMessage(1, "请将道具直接点在你需要刻名的装备上.");

                    break;

                }
                /*  427 */
                if (itemId == 5060001 || itemId == 5061000 || itemId == 5061001 || itemId == 5061002 || itemId == 5061003) {
                    /*  428 */
                    MapleInventoryType type = MapleInventoryType.getByType((byte) slea.readInt());
                    /*  429 */
                    Item item1 = chr.getInventory(type).getItem((short) slea.readInt());
                    /*  430 */
                    if (item1 != null && item1.getExpiration() == -1L) {
                        /*  431 */
                        short flag = item1.getFlag();
                        /*  432 */
                        flag = (short) (flag | ItemFlag.封印.getValue());
                        /*  433 */
                        item1.setFlag(flag);
                        /*  434 */
                        long days = 0L;
                        /*  435 */
                        if (itemId == 5061000) {
                            /*  436 */
                            days = 7L;
                            /*  437 */
                        } else if (itemId == 5061001) {
                            /*  438 */
                            days = 30L;
                            /*  439 */
                        } else if (itemId == 5061002) {
                            /*  440 */
                            days = 90L;
                            /*  441 */
                        } else if (itemId == 5061003) {
                            /*  442 */
                            days = 365L;

                        }
                        /*  444 */
                        if (chr.isAdmin()) {
                            /*  445 */
                            chr.dropMessage(5, "使用封印之锁 物品ID: " + itemId + " 天数: " + days);

                        }
                        /*  447 */
                        if (days > 0L) {
                            /*  448 */
                            item1.setExpiration(System.currentTimeMillis() + days * 24L * 60L * 60L * 1000L);

                        }
                        /*  450 */
                        chr.forceUpdateItem(item1);
                        /*  451 */
                        used = true;

                        break;

                    }
                    /*  454 */
                    chr.dropMessage(1, "使用道具出现错误.");

                    break;

                }
                /*  457 */
                if (itemId == 5064000 || itemId == 5064003) {

                    Item item1;
                    /*  459 */
                    short dst = slea.readShort();
                    /*  460 */
                    if (dst < 0) {
                        /*  461 */
                        item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);

                    } else {
                        /*  463 */
                        item1 = chr.getInventory(MapleInventoryType.EQUIP).getItem(dst);

                    }
                    /*  465 */
                    if (item1 != null && item1.getType() == 1) {
                        /*  466 */
                        int maxEnhance = (itemId == 5064003) ? 7 : 12;
                        /*  467 */
                        if (((Equip) item1).getEnhance() >= maxEnhance) {
                            /*  468 */
                            chr.dropMessage(1, "该道具已无法继续使用防爆卷轴效果.");

                            break;

                        }
                        /*  471 */
                        if (!ItemFlag.装备防爆.check(item1.getFlag())) {


                            /*  474 */
                            item1.addFlag((short) ItemFlag.装备防爆.getValue());
                            /*  475 */
                            chr.forceUpdateItem(item1);
                            /*  476 */
                            chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), itemId, item1.getItemId()), true);
                            /*  477 */
                            used = true;
                            break;

                        }
                        /*  479 */
                        chr.dropMessage(1, "已经获得了相同效果。");


                        break;

                    }
                    /*  483 */
                    chr.dropMessage(1, "请将卷轴点在你需要保护的装备上.");

                    break;

                }
                /*  486 */
                if (itemId == 5064100) {

                    Item item1;
                    /*  488 */
                    short dst = slea.readShort();
                    /*  489 */
                    if (dst < 0) {
                        /*  490 */
                        item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);

                    } else {
                        /*  492 */
                        item1 = null;

                    }
                    /*  494 */
                    if (item1 != null && item1.getType() == 1) {
                        /*  495 */
                        if (!ItemFlag.保护升级次数.check(item1.getFlag())) {


                            /*  498 */
                            item1.addFlag((short) ItemFlag.保护升级次数.getValue());
                            /*  499 */
                            chr.forceUpdateItem(item1);
                            /*  500 */
                            chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), itemId, item1.getItemId()), true);
                            /*  501 */
                            used = true;
                            break;

                        }
                        /*  503 */
                        chr.dropMessage(5, "已经获得了相同效果。");


                        break;

                    }
                    /*  507 */
                    chr.dropMessage(5, "请将卷轴点在你需要保护的装备上.");

                    break;

                }
                /*  510 */
                if (itemId == 5064200) {

                    Item item1;
                    /*  512 */
                    short dst = slea.readShort();
                    /*  513 */
                    if (dst < 0) {
                        /*  514 */
                        item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);

                    } else {
                        /*  516 */
                        item1 = null;

                    }
                    /*  518 */
                    if (item1 != null && item1.getType() == 1) {
                        /*  519 */
                        if (!ItemFlag.封印.check(item1.getFlag()) && !ItemFlag.宿命剪刀.check(item1.getFlag()) && !ItemFlag.转存吊牌.check(item1.getFlag())) {
                            /*  520 */
                            Equip nEquip = ii.resetEquipStats((Equip) item1);
                            /*  521 */
                            chr.forceUpdateItem((Item) nEquip);
                            /*  522 */
                            chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), itemId, item1.getItemId()), true);
                            /*  523 */
                            used = true;
                            break;

                        }
                        /*  525 */
                        chr.dropMessage(5, "该道具无法使用完美还原卷。");


                        break;

                    }
                    /*  529 */
                    chr.dropMessage(5, "请将卷轴点在你需要还原的装备上.");

                    break;

                }
                /*  532 */
                if (itemId == 5064300) {

                    Item item1;
                    /*  534 */
                    short dst = slea.readShort();
                    /*  535 */
                    if (dst < 0) {
                        /*  536 */
                        item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);

                    } else {
                        /*  538 */
                        item1 = null;

                    }
                    /*  540 */
                    if (item1 != null && item1.getType() == 1) {
                        /*  541 */
                        if (!ItemFlag.卷轴防护.check(item1.getFlag())) {
                            /*  542 */
                            item1.addFlag((short) ItemFlag.卷轴防护.getValue());
                            /*  543 */
                            chr.forceUpdateItem(item1);
                            /*  544 */
                            chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), itemId, item1.getItemId()), true);
                            /*  545 */
                            used = true;
                            break;

                        }
                        /*  547 */
                        chr.dropMessage(5, "已经获得了相同效果。");


                        break;

                    }
                    /*  551 */
                    chr.dropMessage(5, "请将卷轴点在你需要保护的装备上.");

                    break;

                }
                /*  554 */
                if (itemId == 5060003) {
                    /*  555 */
                    Item item1 = chr.getInventory(MapleInventoryType.ETC).findById(4170023);
                    /*  556 */
                    if (item1 == null || item1.getQuantity() <= 0) {

                        return;

                    }
                    /*  559 */
                    if (getIncubatedItems(c, itemId, slot)) {
                        /*  560 */
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, item1.getPosition(), (short) 1, false);
                        /*  561 */
                        used = true;

                    }
                    break;

                }
                /*  564 */
                if ((itemId >= 5062000 && itemId < 5062200) || itemId == 5062502 || itemId == 5062503) {
                    /*  565 */
                    Equip equip = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem((short) slea.readInt());
                    /*  566 */
                    int lockslot = 0;
                    /*  567 */
                    short lockid = 0;
                    /*  568 */
                    if (itemId == 5062000) {
                        /*  569 */
                        lockslot = slea.readInt();
                        /*  570 */
                        lockid = slea.readShort();

                    }

                    /*  573 */
                    if (equip != null) {
                        /*  574 */
                        used = equip.resetPotential(itemId, chr, lockslot, lockid);
                        /*  575 */
                        if (used) {
                            /*  576 */
                            chr.equipChanged();

                        }

                    }
                    /*  579 */
                    if (equip == null || !used)
                        /*  580 */
                        chr.getMap().broadcastMessage(InventoryPacket.showPotentialReset(false, chr.getId(), false, itemId, 0));

                    break;

                }
                /*  583 */
                if (itemId == 5062400 || itemId == 5062402) {


                    /*  586 */
                    byte skinSlot = (byte) slea.readInt();
                    /*  587 */
                    byte itemSlot = (byte) slea.readInt();
                    /*  588 */
                    Equip toItem = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem((short) itemSlot);
                    /*  589 */
                    Equip skin = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem((short) skinSlot);
                    /*  590 */
                    if (toItem != null && skin != null && chr.getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1) {
                        /*  591 */
                        MapleInventoryManipulator.addById(c, 2028093, (short) 1, "使用神奇铁砧 时间: " + DateUtil.getCurrentDate());
                        /*  592 */
                        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short) skinSlot, (short) 1, false, true);
                        /*  593 */
                        toItem.setItemSkin((skin.getItemSkin() > 0) ? skin.getItemSkin() : skin.getItemId());
                        /*  594 */
                        chr.forceUpdateItem((Item) toItem);
                        /*  595 */
                        c.announce(InventoryPacket.showSynthesizingMsg(itemId, 2028093, true));
                        /*  596 */
                        chr.finishAchievement(57);
                        /*  597 */
                        used = true;

                        break;

                    }
                    /*  600 */
                    c.announce(InventoryPacket.showSynthesizingMsg(itemId, 2028093, false));

                    break;

                }
                /*  603 */
                if (itemId == 5062500 || itemId == 5062501) {
                    /*  604 */
                    Item item1 = chr.getInventory(MapleInventoryType.EQUIP).getItem((short) slea.readInt());
                    /*  605 */
                    if (item1 != null) {
                        /*  606 */
                        Equip eq = (Equip) item1;
                        /*  607 */
                        used = eq.resetPotential(itemId, chr, 0, (short) 0);
                        /*  608 */
                        if (used) {
                            /*  609 */
                            chr.equipChanged();

                        }

                    }
                    /*  612 */
                    if (item1 == null || !used)
                        /*  613 */ chr.getMap().broadcastMessage(InventoryPacket.潜能变化效果(chr.getId(), false, itemId));

                    break;

                }
                /*  616 */
                if (itemId == 5068100) {
                    /*  617 */
                    short dst = slea.readShort();
                    /*  618 */
                    if (dst == 0) {
                        /*  619 */
                        chr.dropMessage(5, "请将卷轴点在你需要保护的宠物装备上");
                        break;
                        /*  620 */
                    }
                    if (dst == -114 || dst == -122 || dst == -124) {
                        /*  621 */
                        Item item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
                        /*  622 */
                        if (item1 != null) {
                            /*  623 */
                            short flag = item1.getFlag();
                            /*  624 */
                            if (!ItemFlag.保护升级次数.check(flag)) {
                                /*  625 */
                                flag = (short) (flag | ItemFlag.保护升级次数.getValue());
                                /*  626 */
                                item1.setFlag(flag);

                                /*  628 */
                                chr.forceUpdateItem(item1);
                                /*  629 */
                                chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), itemId, item1.getItemId()), true);
                                /*  630 */
                                used = true;
                                break;

                            }
                            /*  632 */
                            chr.dropMessage(5, "已经获得了相同效果。");

                        }

                        break;

                    }
                    /*  636 */
                    chr.dropMessage(5, "该卷轴只能用于宠物装备上。");
                    break;

                }
                /*  638 */
                if (itemId == 5068200) {
                    /*  639 */
                    short dst = slea.readShort();
                    /*  640 */
                    if (dst == 0) {
                        /*  641 */
                        chr.dropMessage(5, "请将卷轴点在你需要保护的宠物装备上");
                        break;
                        /*  642 */
                    }
                    if (dst == -114 || dst == -122 || dst == -124) {
                        /*  643 */
                        Item item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
                        /*  644 */
                        if (item1 != null) {
                            /*  645 */
                            short flag = item1.getFlag();

                            /*  647 */
                            if (!ItemFlag.卷轴防护.check(flag)) {
                                /*  648 */
                                flag = (short) (flag | ItemFlag.卷轴防护.getValue());
                                /*  649 */
                                item1.setFlag(flag);

                                /*  651 */
                                chr.forceUpdateItem(item1);
                                /*  652 */
                                chr.getMap().broadcastMessage(chr, InventoryPacket.getScrollEffect(chr.getId(), itemId, item1.getItemId()), true);
                                /*  653 */
                                used = true;
                                break;

                            }
                            /*  655 */
                            chr.dropMessage(5, "已经获得了相同效果。");

                        }

                        break;

                    }
                    /*  659 */
                    chr.dropMessage(5, "该卷轴只能用于宠物装备上。");
                    break;

                }
                /*  661 */
                if (itemId == 5060002) {
                    /*  662 */
                    byte inventory2 = (byte) slea.readInt();
                    /*  663 */
                    short slot2 = (short) slea.readInt();
                    /*  664 */
                    Item item2 = chr.getInventory(MapleInventoryType.getByType(inventory2)).getItem(slot2);
                    /*  665 */
                    if (item2 == null) {

                        return;

                    }
                    /*  668 */
                    chr.dropMessage(1, "暂时无法使用这个道具.");
                    break;
                    /*  669 */
                }
                if (itemId == 5062800 || itemId == 5062801) {



























                    /*  697 */
                    if (c.getPlayer().getInnerRank() > 0) {
                        /*  698 */
                        c.getPlayer().renewInnerSkills(itemId);
                        /*  699 */
                        chr.equipChanged();
                        /*  700 */
                        chr.dropMessage(1, "能力重新设置成功");
                        /*  701 */
                        used = true;
                        break;

                    }
                    /*  703 */
                    chr.dropMessage(5, "能在能力需要在A级以上才可以使用。");
                    break;

                }
                /*  705 */
                if (itemId == 5060052) {

                    int chairid;

                    do {
                        /*  708 */
                        chairid = Randomizer.nextInt(5000) + 3010000;
                        /*  709 */
                    } while (ii.getName(chairid) == null);

                    /*  711 */
                    if (chr.getSpace(3) >= 1) {
                        /*  712 */
                        used = true;
                        /*  713 */
                        MapleInventoryManipulator.addById(c, chairid, (short) 1, "通过<椅子工具箱> ItemID: " + itemId + " 获得时间：" + DateUtil.getNowTime());
                        /*  714 */
                        chr.dropMessage(1, "恭喜你，\n\r你获得了一个<" + ii.getName(chairid) + ">.");
                        break;

                    }
                    /*  716 */
                    c.getPlayer().dropMessage(5, "背包空间不足。");

                    break;

                }
                /*  719 */
                if (itemId == 5060049) {
                    /*  720 */
                    List<Integer> list = (List<Integer>) ii.getDamageSkinBox().keySet().parallelStream().collect(Collectors.toList());
                    /*  721 */
                    int intValue = ((Integer) list.get(Randomizer.nextInt(list.size()))).intValue();
                    /*  722 */
                    if (chr.getSpace(2) >= 1) {
                        /*  723 */
                        used = true;
                        /*  724 */
                        MapleInventoryManipulator.addById(c, intValue, (short) 1, "通过<伤害皮肤卡牌包> ItemID: " + itemId + " 获得时间：" + DateUtil.getNowTime());
                        /*  725 */
                        chr.dropMessage(1, "恭喜你，\n\r你获得了一个<" + ii.getName(intValue) + ">.");
                        break;

                    }
                    /*  727 */
                    c.getPlayer().dropMessage(5, "背包空间不足。");




                    break;

                }


                /*  735 */
                chr.dropMessage(1, "暂时无法使用这个道具.");

                break;



            case 507:
                /*  740 */
                if (chr.isAdmin()) {
                    /*  741 */
                    chr.dropMessage(5, "使用商场喇叭 道具类型: " + (itemId / 1000 % 10));

                }
                /*  743 */
                if (chr.getLevel() < 10) {
                    /*  744 */
                    chr.dropMessage(5, "需要等级10级才能使用这个道具.");

                    break;

                }
                /*  747 */
                if (chr.getMapId() == 180000001) {
                    /*  748 */
                    chr.dropMessage(5, "在这个地方无法使用这个道具.");

                    break;

                }
                /*  751 */
                if (!chr.getCheatTracker().canSmega() && !chr.isGM()) {
                    /*  752 */
                    chr.dropMessage(5, "你需要等待3秒之后才能使用这个道具.");

                    break;

                }
                /*  755 */
                if (!c.getChannelServer().getMegaphoneMuteState()) {
                    /*  756 */
                    int tvType;
                    boolean megassenger, tvEar;
                    MapleCharacter victim;
                    List<String> tvMessages;
                    StringBuilder builder;
                    String message, djmsg;
                    boolean sjEar;
                    Item item1;
                    byte numLines;
                    List<String> bfMessages;
                    int k;
                    boolean bfEar;
                    int msgType = itemId / 1000 % 10;
                    /*  757 */
                    used = true;
                    /*  758 */
                    switch (msgType) {

                        case 0:
                            /*  760 */
                            chr.getMap().broadcastMessage(MaplePacketCreator.serverNotice(2, chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString()));

                            break;

                        case 1:
                            /*  763 */
                            c.getChannelServer().broadcastSmegaPacket(MaplePacketCreator.serverNotice(2, chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString()));

                            break;

                        case 2:
                            /*  766 */
                            WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.serverNotice(3, c.getChannel(), chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString(), (slea.readByte() != 0)));

                            break;

                        case 3:
                            /*  769 */
                            WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.serverNotice(51, c.getChannel(), chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString(), (slea.readByte() != 0)));

                            break;

                        case 4:
                            /*  772 */
                            WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.serverNotice(52, c.getChannel(), chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString(), (slea.readByte() != 0)));

                            break;

                        case 5:
                            /*  775 */
                            tvType = itemId % 10;
                            /*  776 */
                            megassenger = false;
                            /*  777 */
                            tvEar = false;
                            /*  778 */
                            victim = null;
                            /*  779 */
                            if (tvType != 1) {
                                /*  780 */
                                if (tvType >= 3) {
                                    /*  781 */
                                    megassenger = true;
                                    /*  782 */
                                    if (tvType == 3) {
                                        /*  783 */
                                        slea.readByte();

                                    }
                                    /*  785 */
                                    tvEar = (1 == slea.readByte());
                                    /*  786 */
                                } else if (tvType != 2) {
                                    /*  787 */
                                    slea.readByte();

                                }
                                /*  789 */
                                if (tvType != 4) {
                                    /*  790 */
                                    victim = c.getChannelServer().getPlayerStorage().getCharacterByName(slea.readMapleAsciiString());

                                }

                            }
                            /*  793 */
                            tvMessages = new LinkedList<>();
                            /*  794 */
                            builder = new StringBuilder();
                            /*  795 */
                            message = slea.readMapleAsciiString();
                            /*  796 */
                            if (megassenger) {
                                /*  797 */
                                builder.append(" ").append(message);

                            }
                            /*  799 */
                            tvMessages.add(message);

                            /*  801 */
                            if (!MapleTVEffect.isActive()) {
                                /*  802 */
                                if (megassenger) {
                                    /*  803 */
                                    String text = builder.toString();
                                    /*  804 */
                                    if (text.length() <= 60) {
                                        /*  805 */
                                        WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.serverNotice(3, c.getChannel(), chr.getName() + " : " + builder.toString(), tvEar));

                                    }

                                }
                                /*  808 */
                                MapleTVEffect mapleTVEffect = new MapleTVEffect(chr, victim, tvMessages, tvType);
                                /*  809 */
                                mapleTVEffect.stratMapleTV();
                                break;

                            }
                            /*  811 */
                            chr.dropMessage(1, "冒险岛TV正在使用中");
                            /*  812 */
                            used = false;

                            break;


                        case 6:
                            /*  816 */
                            djmsg = chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString();
                            /*  817 */
                            sjEar = (slea.readByte() > 0);
                            /*  818 */
                            item1 = null;
                            /*  819 */
                            if (slea.readByte() == 1) {
                                /*  820 */
                                byte invType = (byte) slea.readInt();
                                /*  821 */
                                byte pos = (byte) slea.readInt();
                                /*  822 */
                                item1 = chr.getInventory(MapleInventoryType.getByType(invType)).getItem((short) pos);

                            }
                            /*  824 */
                            WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.itemMegaphone(djmsg, sjEar, c.getChannel(), item1));

                            break;

                        case 7:
                            /*  827 */
                            numLines = slea.readByte();
                            /*  828 */
                            if (numLines < 1 || numLines > 3) {

                                return;

                            }
                            /*  831 */
                            bfMessages = new LinkedList<>();

                            /*  833 */
                            for (k = 0; k < numLines; k++) {
                                /*  834 */
                                String bfMsg = slea.readMapleAsciiString();
                                /*  835 */
                                if (bfMsg.length() > 65) {

                                    break;

                                }
                                /*  838 */
                                bfMessages.add(chr.getName() + " : " + bfMsg);

                            }
                            /*  840 */
                            bfEar = (slea.readByte() > 0);
                            /*  841 */
                            WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.tripleSmega(bfMessages, bfEar, c.getChannel()));

                            break;

                        case 9:
                            /*  844 */
                            WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.serverNotice((itemId == 5079001) ? 24 : 25, c.getChannel(), chr.getMedalText() + chr.getName() + " : " + slea.readMapleAsciiString(), (slea.readByte() != 0)));
                            break;

                    }

                    break;

                }
                /*  848 */
                chr.dropMessage(5, "当前频道禁止使用道具喇叭.");

                break;



            case 508:
                /*  853 */
                love = new MapleLove(chr, chr.getPosition(), chr.getMap().getFootholds().findBelow(chr.getPosition(), true).getId(), slea.readMapleAsciiString(), itemId);
                /*  854 */
                chr.getMap().spawnLove(love);
                /*  855 */
                used = true;

                break;


            case 509:
                /*  859 */
                sendTo = slea.readMapleAsciiString();
                /*  860 */
                str1 = slea.readMapleAsciiString();
                /*  861 */
                chr.sendNote(sendTo, str1);
                /*  862 */
                used = true;

                break;



            case 510:
                /*  867 */
                chr.getMap().startJukebox(chr.getName(), itemId);
                /*  868 */
                used = true;

                break;


            case 512:
                /*  872 */
                msg = ii.getMsg(itemId);
                /*  873 */
                ourMsg = slea.readMapleAsciiString();
                /*  874 */
                if (!msg.contains("%s")) {
                    /*  875 */
                    msg = ourMsg;

                } else {
                    /*  877 */
                    msg = msg.replaceFirst("%s", chr.getName());
                    /*  878 */
                    if (!msg.contains("%s")) {
                        /*  879 */
                        msg = ii.getMsg(itemId).replaceFirst("%s", ourMsg);

                    } else {

                        try {
                            /*  882 */
                            msg = msg.replaceFirst("%s", ourMsg);
                            /*  883 */
                        } catch (Exception e) {
                            /*  884 */
                            msg = ii.getMsg(itemId).replaceFirst("%s", ourMsg);

                        }

                    }

                }
                /*  888 */
                chr.getMap().startMapEffect(msg, itemId);
                /*  889 */
                buff = ii.getStateChangeItem(itemId);
                /*  890 */
                if (buff != 0) {
                    /*  891 */
                    for (MapleCharacter mChar : chr.getMap().getCharactersThreadsafe()) {
                        /*  892 */
                        ii.getItemEffect(buff).applyTo(mChar);

                    }

                }
                /*  895 */
                used = true;

                break;













            case 515:
                /*  910 */
                if (itemId >= 5152100 && itemId <= 5152107) {
                    /*  911 */
                    int color = (itemId - 5152100) * 100;

                    /*  913 */
                    if (color >= 0 && c.getPlayer().changeFace(color)) {
                        /*  914 */
                        used = true;
                        break;

                    }
                    /*  916 */
                    chr.dropMessage(1, "使用一次性隐形眼镜出现错误.");
                    break;

                }
                /*  918 */
                if (itemId == 5155000) {
                    /*  919 */
                    chr.changeElfEar();
                    /*  920 */
                    used = true;
                    break;
                    /*  921 */
                }
                if (itemId == 5156000) {
                    /*  922 */
                    if (chr.getMarriageId() > 0 || chr.getMarriageRing() != null) {
                        /*  923 */
                        chr.dropSpouseMessage(11, "已婚人士无法使用。");
                        break;
                        /*  924 */
                    }
                    if (JobConstants.is米哈尔(chr.getJob()) || JobConstants.is爆莉萌天使(chr.getJob())) {
                        /*  925 */
                        chr.dropSpouseMessage(11, "该职业群无法使用的物品。");
                        break;

                    }
                    /*  927 */
                    chr.setGender((chr.getGender() == 0) ? (byte) 1 : (byte) 0);
                    /*  928 */
                    Pair<Integer, Integer> ret = JobConstants.getDefaultFaceAndHair(chr.getJob(), chr.getGender());
                    /*  929 */
                    List<Pair<MapleStat, Long>> statupdate = new ArrayList<>(3);
                    /*  930 */
                    chr.setFace(((Integer) ret.getLeft()).intValue());
                    /*  931 */
                    chr.setHair(((Integer) ret.getRight()).intValue());
                    /*  932 */
                    statupdate.add(new Pair(MapleStat.脸型, Long.valueOf(chr.getFace())));
                    /*  933 */
                    statupdate.add(new Pair(MapleStat.发型, Long.valueOf(chr.getHair())));
                    /*  934 */
                    statupdate.add(new Pair(MapleStat.性别, Long.valueOf(chr.getGender())));
                    /*  935 */
                    c.announce(MaplePacketCreator.updatePlayerStats(statupdate, chr));
                    /*  936 */
                    c.announce(EffectPacket.showOwnCraftingEffect("Effect/BasicEff.img/TransGender", 0, 0));
                    /*  937 */
                    chr.getMap().broadcastMessage(chr, EffectPacket.showCraftingEffect(chr.getId(), "Effect/BasicEff.img/TransGender", 0, 0), false);
                    /*  938 */
                    c.announce(MaplePacketCreator.spawnPlayerMapobject(chr));
                    /*  939 */
                    chr.equipChanged();
                    /*  940 */
                    used = true;

                    break;

                }
                /*  943 */
                chr.dropMessage(1, "暂不支持这个道具的使用.");

                break;



            case 517:
                /*  948 */
                uniqueid = (int) slea.readLong();
                /*  949 */
                maplePet1 = null;
                /*  950 */
                for (MaplePet petx : chr.getPets()) {
                    /*  951 */
                    if (petx != null && petx.getUniqueId() == uniqueid) {
                        /*  952 */
                        maplePet1 = petx;

                        break;

                    }

                }
                /*  956 */
                if (maplePet1 == null) {
                    /*  957 */
                    chr.dropMessage(1, "宠物改名错误，找不到宠物的信息.");

                    break;

                }
                /*  960 */
                str2 = slea.readMapleAsciiString();
                /*  961 */
                for (String z : GameConstants.RESERVED) {
                    /*  962 */
                    if (maplePet1.getName().contains(z) || str2.contains(z)) {

                        break;

                    }

                }
                /*  966 */
                if (MapleCharacterUtil.canChangePetName(str2)) {
                    /*  967 */
                    maplePet1.setName(str2);
                    /*  968 */
                    maplePet1.saveToDb();
                    /*  969 */
                    chr.petUpdateStats(maplePet1, true);
                    /*  970 */
                    c.announce(MaplePacketCreator.enableActions());
                    /*  971 */
                    chr.getMap().broadcastMessage(MTSCSPacket.INSTANCE.changePetName(chr, str2, maplePet1.getInventoryPosition()));
                    /*  972 */
                    used = true;

                }

                break;


            case 519:
                /*  977 */
                if (itemId >= 5190000 && itemId <= 5190011) {
                    /*  978 */
                    uniqueid = (int) slea.readLong();
                    /*  979 */
                    maplePet1 = null;
                    /*  980 */
                    for (MaplePet petx : chr.getPets()) {
                        /*  981 */
                        if (petx != null && petx.getUniqueId() == uniqueid) {
                            /*  982 */
                            maplePet1 = petx;

                            break;

                        }

                    }
                    /*  986 */
                    if (maplePet1 == null) {
                        /*  987 */
                        chr.dropMessage(1, "宠物改名错误，找不到宠物的信息.");

                        break;

                    }
                    /*  990 */
                    PetFlag petFlag = PetFlag.getByAddId(itemId);
                    /*  991 */
                    if (petFlag != null && !petFlag.check(maplePet1.getFlags())) {
                        /*  992 */
                        maplePet1.setFlags(maplePet1.getFlags() | petFlag.getValue());
                        /*  993 */
                        maplePet1.saveToDb();
                        /*  994 */
                        chr.petUpdateStats(maplePet1, true);
                        /*  995 */
                        c.announce(MaplePacketCreator.enableActions());
                        /*  996 */
                        c.announce(MTSCSPacket.INSTANCE.changePetFlag(uniqueid, true, petFlag.getValue()));
                        /*  997 */
                        used = true;

                    }
                    break;

                }
                /* 1000 */
                if (itemId >= 5191000 && itemId <= 5191004) {
                    /* 1001 */
                    uniqueid = (int) slea.readLong();
                    /* 1002 */
                    maplePet1 = null;
                    /* 1003 */
                    for (MaplePet petx : chr.getPets()) {
                        /* 1004 */
                        if (petx != null && petx.getUniqueId() == uniqueid) {
                            /* 1005 */
                            maplePet1 = petx;

                            break;

                        }

                    }
                    /* 1009 */
                    if (maplePet1 == null) {
                        /* 1010 */
                        chr.dropMessage(1, "宠物改名错误，找不到宠物的信息.");

                        break;

                    }
                    /* 1013 */
                    PetFlag petFlag = PetFlag.getByDelId(itemId);
                    /* 1014 */
                    if (petFlag != null && petFlag.check(maplePet1.getFlags())) {
                        /* 1015 */
                        maplePet1.setFlags(maplePet1.getFlags() - petFlag.getValue());
                        /* 1016 */
                        maplePet1.saveToDb();
                        /* 1017 */
                        chr.petUpdateStats(maplePet1, true);
                        /* 1018 */
                        c.announce(MaplePacketCreator.enableActions());
                        /* 1019 */
                        c.announce(MTSCSPacket.INSTANCE.changePetFlag(uniqueid, false, petFlag.getValue()));
                        /* 1020 */
                        used = true;

                    }
                    break;
                    /* 1022 */
                }
                if (itemId == 5192000) {
                    /* 1023 */
                    MaplePet maplePet = null;
                    /* 1024 */
                    int petuid = (int) slea.readLong();
                    /* 1025 */
                    for (MaplePet p : chr.getPets()) {
                        /* 1026 */
                        if (p != null && p.getUniqueId() == petuid) {
                            /* 1027 */
                            maplePet = p;

                            break;

                        }

                    }
                    /* 1031 */
                    if (maplePet == null) {
                        /* 1032 */
                        chr.dropMessage(1, "宠物训练技能失败,找不到对应宠物信息。");

                        break;

                    }
                    /* 1035 */
                    maplePet.setAddSkill(Randomizer.nextInt(6) + 1);
                    /* 1036 */
                    maplePet.saveToDb();
                    /* 1037 */
                    c.announce(InventoryPacket.updatePet(maplePet, chr.getInventory(MapleInventoryType.CASH).getItem(maplePet.getInventoryPosition()), maplePet.getSummoned()));
                    /* 1038 */
                    c.announce(InventoryPacket.petAddSkill(chr, maplePet));
                    /* 1039 */
                    c.sendEnableActions();
                    /* 1040 */
                    used = true;

                }

                break;



            case 520:
                /* 1046 */
                if (itemId >= 5200000 && itemId <= 5200008) {
                    /* 1047 */
                    if (chr.isIntern()) {
                        /* 1048 */
                        int mesars = ii.getMeso(itemId);
                        /* 1049 */
                        if (mesars > 0 && chr.getMeso() < (Integer.MAX_VALUE - mesars)) {
                            /* 1050 */
                            used = true;
                            /* 1051 */
                            if (Math.random() > 0.1D) {
                                /* 1052 */
                                int gainmes = Randomizer.nextInt(mesars);
                                /* 1053 */
                                chr.gainMeso(gainmes, false);
                                /* 1054 */
                                c.announce(MTSCSPacket.INSTANCE.sendMesobagSuccess(gainmes));
                                break;

                            }
                            /* 1056 */
                            c.announce(MTSCSPacket.INSTANCE.sendMesobagFailed());

                            break;

                        }
                        /* 1059 */
                        chr.dropMessage(1, "金币已达到上限无法使用这个道具.");

                        break;

                    }
                    /* 1062 */
                    AutobanManager.getInstance().autoban(chr.getClient(), "使用非法道具.");


                    break;

                }
                /* 1066 */
                chr.dropMessage(5, "暂时无法使用这个道具.");

                break;



            case 523:
                /* 1071 */
                itemSearch = slea.readInt();
                /* 1072 */
                hms = c.getChannelServer().searchMerchant(itemSearch);
                /* 1073 */
                if (hms.size() > 0) {
                    /* 1074 */
                    c.announce(MaplePacketCreator.getOwlSearched(itemSearch, hms));
                    /* 1075 */
                    used = true;

                } else {
                    /* 1077 */
                    chr.dropMessage(1, "没有找到这个道具.");

                }
                /* 1079 */
                MapleCharacterUtil.addToItemSearch(itemSearch);

                break;


            case 524:
                /* 1083 */
                pet = null;
                /* 1084 */
                pets = chr.getSpawnPets();
                /* 1085 */
                for (i = 0; i < 3; i++) {
                    /* 1086 */
                    if (pets[i] != null && (pets[i].canConsume(itemId) || itemId == 5249000)) {
                        /* 1087 */
                        pet = pets[i];

                        break;

                    }

                }
                /* 1091 */
                if (pet == null) {
                    /* 1092 */
                    chr.dropMessage(1, "没有可以喂食的宠物。\r\n请重新确认。");

                    break;

                }
                /* 1095 */
                petIndex = chr.getPetIndex(pet);
                /* 1096 */
                pet.setFullness(100);
                /* 1097 */
                if (pet.getCloseness() < 30000) {
                    /* 1098 */
                    pet.setCloseness(Math.min((itemId == 5249000) ? (pet.getCloseness() + 100) : (pet.getCloseness() + 100 * ServerConfig.CHANNEL_RATE_TRAIT), 30000));
                    /* 1099 */
                    while (pet.getCloseness() >= GameConstants.getClosenessNeededForLevel(pet.getLevel() + 1)) {
                        /* 1100 */
                        pet.setLevel(pet.getLevel() + 1);
                        /* 1101 */
                        c.announce(EffectPacket.showOwnPetLevelUp(chr.getPetIndex(pet)));
                        /* 1102 */
                        chr.getMap().broadcastMessage(PetPacket.showPetLevelUp(chr, petIndex));

                    }

                }
                /* 1105 */
                chr.petUpdateStats(pet, true);
                /* 1106 */
                chr.getMap().broadcastMessage(chr, PetPacket.commandResponse(chr.getId(), (byte) 1, (short) petIndex, true, true), true);
                /* 1107 */
                used = true;

                break;


            case 528:
                /* 1111 */
                bounds = new Rectangle((int) chr.getPosition().getX(), (int) chr.getPosition().getY(), 1, 1);
                /* 1112 */
                mist = new MapleMist(bounds, chr);
                /* 1113 */
                chr.getMap().spawnMist(mist, 10000, true);
                /* 1114 */
                c.announce(MaplePacketCreator.enableActions());
                /* 1115 */
                used = true;

                break;


            case 532:
                name = slea.readMapleAsciiString();
                otherName = slea.readMapleAsciiString();
                slea.readInt();
                slea.readInt();
                int cardId = slea.readByte();
                pcf = PredictCardFactory.getInstance();
                Card = pcf.getPredictCard(cardId);
                commentId = Randomizer.nextInt(pcf.getCardCommentSize());
                Comment = pcf.getPredictCardComment(commentId);
                if (Card != null && Comment != null) {
                    chr.dropMessage(5, "占卜只是随便写的，占卜结果就当个玩笑看看。");
                    int love1 = Randomizer.rand(1, Comment.score) + 5;
                    c.announce(MaplePacketCreator.showPredictCard(name, otherName, love1, cardId, commentId));
                    used = true;
                }
                break;


            case 537:
                /* 1137 */
                chr.setChalkboard(slea.readMapleAsciiString());

                break;


            case 539:
                /* 1141 */
                if (chr.getLevel() < 10) {
                    /* 1142 */
                    chr.dropMessage(5, "需要等级10级才能使用这个道具.");

                    break;

                }
                /* 1145 */
                if (chr.getMapId() == 180000001) {
                    /* 1146 */
                    chr.dropMessage(5, "当前地图无法使用这个道具.");

                    break;

                }
                /* 1149 */
                if (!chr.getCheatTracker().canAvatarSmega()) {
                    /* 1150 */
                    chr.dropMessage(5, "你需要等待6秒之后才能使用这个道具.");

                    break;

                }
                /* 1153 */
                if (!c.getChannelServer().getMegaphoneMuteState()) {
                    /* 1154 */
                    List<String> messages = new LinkedList<>();
                    /* 1155 */
                    for (int k = 0; k < 4; k++) {
                        /* 1156 */
                        messages.add(slea.readMapleAsciiString());

                    }
                    /* 1158 */
                    boolean ear = (slea.readByte() != 0);
                    /* 1159 */
                    WorldBroadcastService.getInstance().broadcastSmega(MaplePacketCreator.getAvatarMega(chr, c.getChannel(), itemId, messages, ear));
                    /* 1160 */
                    used = true;
                    break;

                }
                /* 1162 */
                chr.dropMessage(5, "当前频道禁止使用情景喇叭.");

                break;




            case 545:
                /* 1168 */
                if (ServerConstants.isBlockedMapFM(chr.getMapId())) {
                    /* 1169 */
                    chr.dropMessage(5, "当前地图无法使用此道具.");
                    /* 1170 */
                    c.announce(MaplePacketCreator.enableActions());

                    return;

                }
                /* 1173 */
                if (chr.getLevel() < 10) {
                    /* 1174 */
                    chr.dropMessage(5, "只有等级达到10级才可以使用此道具.");
                    break;
                    /* 1175 */
                }
                if (chr.hasBlockedInventory() || chr.getMap().getSquadByMap() != null || chr.getEventInstance() != null || chr.getMap().getEMByMap() != null || chr.getMapId() >= 990000000) {
                    /* 1176 */
                    chr.dropMessage(5, "当前地图无法使用此道具.");
                    break;
                    /* 1177 */
                }
                if ((chr.getMapId() >= 680000210 && chr.getMapId() <= 680000502) || (chr.getMapId() / 1000 == 980000 && chr.getMapId() != 980000000) || chr.getMapId() / 100 == 1030008 || chr.getMapId() / 100 == 922010 || chr.getMapId() / 10 == 13003000) {
                    /* 1178 */
                    chr.dropMessage(5, "当前地图无法使用此道具.");






                    break;

                }




                /* 1190 */
                if (itemId == 5451001) {
                    /* 1191 */
                    chr.dropMessage(1, "暂时无法使用这个道具.");
                    break;
                    /* 1192 */
                }
                if (itemId == 5450001 || itemId == 5450005 || itemId == 5450008 || itemId == 5450009) {
                    /* 1193 */
                    chr.setConversation(4);
                    /* 1194 */
                    chr.getStorage().sendStorage(c, (itemId == 5450001) ? 1002005 : 1022005);
                    break;
                    /* 1195 */
                }
                if (itemId == 5450010) {
                    /* 1196 */
                    MapleShopFactory.getInstance().getShop(9090100).sendItemShop(c, itemId);
                    /* 1197 */
                    used = true;
                    break;

                }
                /* 1199 */
                MapleShopFactory.getInstance().getShop(9090000).sendItemShop(c, itemId);

                break;



            case 550:
                /* 1204 */
                if (itemId == 5500003) {
                    /* 1205 */
                    chr.dropMessage(1, "暂时无法使用这个道具.");
                    break;

                }
                /* 1207 */
                if (itemId == 5501001 || itemId == 5501002) {
                    /* 1208 */
                    Skill skil = SkillFactory.getSkill(slea.readInt());
                    /* 1209 */
                    if (skil == null || skil.getId() / 10000 != 8000 || chr.getSkillLevel(skil) <= 0 || !skil.isTimeLimited() || GameConstants.getMountItem(skil.getId(), chr) <= 0) {

                        break;

                    }
                    /* 1212 */
                    long toAdd = (((itemId == 5501001) ? 30 : 60) * 24 * 60 * 60) * 1000L;
                    /* 1213 */
                    long expire = chr.getSkillExpiry(skil);
                    /* 1214 */
                    if (expire < System.currentTimeMillis() || expire + toAdd >= System.currentTimeMillis() + 31536000000L) {

                        break;

                    }
                    /* 1217 */
                    chr.changeSingleSkillLevel(skil, chr.getSkillLevel(skil), chr.getMasterLevel(skil), expire + toAdd);
                    /* 1218 */
                    used = true;
                    break;

                }
                /* 1220 */
                if (itemId >= 5500000 && itemId <= 5500006) {
                    /* 1221 */
                    Short slots = Short.valueOf(slea.readShort());
                    /* 1222 */
                    if (slots.shortValue() == 0) {
                        /* 1223 */
                        chr.dropMessage(1, "请该道具点在你需要延长时间的道具上.");

                        break;

                    }
                    /* 1226 */
                    Item item1 = chr.getInventory(MapleInventoryType.EQUIPPED).getItem(slots.shortValue());
                    /* 1227 */
                    long days = 0L;
                    /* 1228 */
                    if (itemId == 5500000) {
                        /* 1229 */
                        days = 1L;
                        /* 1230 */
                    } else if (itemId == 5500001) {
                        /* 1231 */
                        days = 7L;
                        /* 1232 */
                    } else if (itemId == 5500002) {
                        /* 1233 */
                        days = 20L;
                        /* 1234 */
                    } else if (itemId == 5500004) {
                        /* 1235 */
                        days = 30L;
                        /* 1236 */
                    } else if (itemId == 5500005) {
                        /* 1237 */
                        days = 50L;
                        /* 1238 */
                    } else if (itemId == 5500006) {
                        /* 1239 */
                        days = 99L;

                    }
                    /* 1241 */
                    if (item1 != null && !ItemConstants.isAccessory(item1.getItemId()) && item1.getExpiration() > -1L && !ii.isCash(item1.getItemId()) && System.currentTimeMillis() + 8640000000L > item1.getExpiration() + days * 24L * 60L * 60L * 1000L) {
                        /* 1242 */
                        boolean change = true;
                        /* 1243 */
                        for (String z : GameConstants.RESERVED) {
                            /* 1244 */
                            if (chr.getName().contains(z) || item1.getOwner().contains(z)) {
                                /* 1245 */
                                change = false;

                            }

                        }
                        /* 1248 */
                        if (change && days > 0L) {
                            /* 1249 */
                            item1.setExpiration(item1.getExpiration() + days * 24L * 60L * 60L * 1000L);
                            /* 1250 */
                            chr.forceUpdateItem(item1);
                            /* 1251 */
                            used = true;

                            break;

                        }
                        /* 1254 */
                        chr.dropMessage(1, "无法使用在这个道具上.");

                        break;

                    }
                    /* 1257 */
                    chr.dropMessage(1, "使用道具出现错误.");

                    break;

                }
                /* 1260 */
                chr.dropMessage(1, "暂时无法使用这个道具.");

                break;



            case 552:
                /* 1265 */
                if (itemId == 5521000) {
                    /* 1266 */
                    MapleInventoryType type = MapleInventoryType.getByType((byte) slea.readInt());
                    /* 1267 */
                    Item item1 = chr.getInventory(type).getItem((short) slea.readInt());
                    /* 1268 */
                    if (item1 != null && !ItemFlag.封印.check(item1.getFlag()) && !ItemFlag.转存吊牌.check(item1.getFlag()) && !ItemFlag.宿命剪刀.check(item1.getFlag()) &&
                            /* 1269 */             ii.isShareTagEnabled(item1.getItemId())) {
                        /* 1270 */
                        short flag = item1.getFlag();
                        /* 1271 */
                        flag = (short) (flag | ItemFlag.不可交易.getValue());
                        /* 1272 */
                        flag = (short) (flag | ItemFlag.可以交换1次.getValue());

                        /* 1274 */
                        if (type == MapleInventoryType.EQUIP) {
                            /* 1275 */
                            flag = (short) (flag | ItemFlag.转存吊牌.getValue());

                        }

                        /* 1278 */
                        item1.setFlag(flag);
                        /* 1279 */
                        chr.forceUpdateItem(item1);
                        /* 1280 */
                        used = true;

                    }

                    break;

                }
                /* 1284 */
                if (itemId == 5520000 || itemId == 5520001) {
                    /* 1285 */
                    MapleInventoryType type = MapleInventoryType.getByType((byte) slea.readInt());
                    /* 1286 */
                    Item item1 = chr.getInventory(type).getItem((short) slea.readInt());
                    /* 1287 */
                    if (item1 != null && !ItemFlag.可以交换1次.check(item1.getFlag()) && !ItemFlag.宿命剪刀.check(item1.getFlag()) && ((
                            /* 1288 */             itemId == 5520000 && ii.isTradeAvailable(item1.getItemId())) || (itemId == 5520001 && ii.isPKarmaEnabled(item1.getItemId())) || (((Equip) item1).getKarmaCount() > 0 && ((Equip) item1).getSealedExp() > 0L))) {
                        /* 1289 */
                        short flag = item1.getFlag();









                        /* 1299 */
                        if (ItemFlag.不可交易.check(flag)) {
                            /* 1300 */
                            flag = (short) (flag - ItemFlag.不可交易.getValue());
                            /* 1301 */
                        } else if (type == MapleInventoryType.EQUIP) {
                            /* 1302 */
                            flag = (short) (flag | ItemFlag.可以交换1次.getValue());

                        } else {
                            /* 1304 */
                            flag = (short) (flag | ItemFlag.鞋子防滑.getValue());

                        }
                        /* 1306 */
                        item1.setFlag(flag);
                        /* 1307 */
                        chr.forceUpdateItem(item1);
                        /* 1308 */
                        used = true;

                    }

                }

                break;




            case 553:
                /* 1316 */
                if (CashItemFactory.getInstance().hasRandomItem(itemId)) {
                    /* 1317 */
                    InventoryHandler.UseRewardBox(slot, itemId, c, chr);
                    break;
                    /* 1318 */
                }
                if (itemId == 5537000) {
                    /* 1319 */
                    if (chr.getSpace(2) < 3) {

                        /* 1321 */
                        chr.dropMessage(1, "请先空出消耗栏3格，再试一次");

                        break;

                    }
                    /* 1324 */
                    InventoryHandler.UseFamiliarCard(chr);
                    /* 1325 */
                    used = true;
                    break;

                }
                /* 1327 */
                if (!InventoryHandler.UseRewardItem(slot, itemId, c, chr)) {
                    /* 1328 */
                    chr.dropMessage(1, "该道具无法使用.道具ID: " + itemId);

                }

                break;



            case 555:
                /* 1334 */
                if (itemId == 5551000) {
                    /* 1335 */
                    int damskinslot = Integer.valueOf(chr.getKeyValue("DAMAGE_SKIN_SLOT")).intValue();
                    /* 1336 */
                    if (damskinslot < 10) {
                        /* 1337 */
                        chr.setKeyValue("DAMAGE_SKIN_SLOT", String.valueOf(damskinslot + 1));
                        /* 1338 */
                        chr.send(MaplePacketCreator.updateDamageSkin(chr, 0));
                        /* 1339 */
                        chr.dropMessage(1, "伤害皮肤栏位扩充成功，当前栏位：" + (damskinslot + 1) + " 格");
                        /* 1340 */
                        used = true;
                        break;

                    }
                    /* 1342 */
                    chr.dropMessage(1, "栏位已满无法扩充。");

                    break;

                }
                /* 1345 */
                chr.dropMessage(1, "该道具无法使用.道具ID: " + itemId);

                break;



            case 557:
                /* 1350 */
                slea.readInt();
                /* 1351 */
                item = (Equip) chr.getInventory(MapleInventoryType.EQUIP).getItem((short) slea.readInt());
                /* 1352 */
                if (item != null) {
                    /* 1353 */
                    if (ItemConstants.canHammer(item.getItemId()) && ii.getSlots(item.getItemId()) > 0 && item.getViciousHammer() < 2) {
                        /* 1354 */
                        item.setViciousHammer((byte) (item.getViciousHammer() + 1));
                        /* 1355 */
                        item.setUpgradeSlots((byte) (item.getUpgradeSlots() + 1));
                        /* 1356 */
                        chr.forceUpdateItem((Item) item);
                        /* 1357 */
                        c.announce(MTSCSPacket.INSTANCE.sendCashHammerUse(true));
                        /* 1358 */
                        used = true;
                        break;

                    }
                    /* 1360 */
                    chr.dropMessage(1, "无法使用在这个道具上.");
                    /* 1361 */
                    c.announce(MTSCSPacket.INSTANCE.sendCashHammerUse(false));

                }

                break;



            case 562:
                /* 1367 */
                if (InventoryHandler.UseSkillBook(slot, itemId, c, chr)) {
                    /* 1368 */
                    chr.gainSP(1);

                }

                break;


            case 570:
                /* 1373 */
                slea.skip(8);
                /* 1374 */
                if (chr.getAndroid() == null) {

                    break;

                }
                /* 1377 */
                nName = slea.readMapleAsciiString();
                /* 1378 */
                for (String z : GameConstants.RESERVED) {
                    /* 1379 */
                    if (chr.getAndroid().getName().contains(z) || nName.contains(z)) {

                        break;

                    }

                }
                /* 1383 */
                if (MapleCharacterUtil.canChangePetName(nName)) {
                    /* 1384 */
                    chr.getAndroid().setName(nName);
                    /* 1385 */
                    chr.getAndroid().saveToDb();
                    /* 1386 */
                    chr.setAndroid(chr.getAndroid());
                    /* 1387 */
                    used = true;

                }

                break;


            case 575:
                /* 1392 */
                if (itemId == 5750000 || itemId == 5750002) {
                    /* 1393 */
                    if (chr.getLevel() < 10) {
                        /* 1394 */
                        chr.dropMessage(1, "使用这个道具需要等级达到10级.");

                        break;

                    }
                    /* 1397 */
                    Item item1 = chr.getInventory(MapleInventoryType.SETUP).getItem((short) slea.readInt());
                    /* 1398 */
                    if (item1 != null && chr.getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 1 && chr.getInventory(MapleInventoryType.SETUP).getNumFreeSlot() >= 1) {
                        /* 1399 */
                        int grade = ItemConstants.getNebuliteGrade(item1.getItemId());
                        /* 1400 */
                        if (grade != -1 && grade < 5) {
                            /* 1401 */
                            int prop = 0;
                            /* 1402 */
                            switch (grade) {

                                case 0:
                                    /* 1404 */
                                    prop = Integer.valueOf(NebuliteConfig.benuliteC).intValue();

                                    break;

                                case 1:
                                    /* 1407 */
                                    prop = Integer.valueOf(NebuliteConfig.benuliteB).intValue();

                                    break;

                                case 2:
                                    /* 1410 */
                                    prop = Integer.valueOf(NebuliteConfig.benuliteA).intValue();

                                    break;

                                case 3:
                                    /* 1413 */
                                    prop = Integer.valueOf(NebuliteConfig.benuliteS).intValue();

                                    break;

                            }

                            /* 1417 */
                            int rank = (Randomizer.nextInt(100) < prop) ? (grade + 1) : grade;
                            /* 1418 */
                            List<StructItemOption> pots = new LinkedList<>(ii.getAllSocketInfo(rank).values());
                            /* 1419 */
                            int newId = 0;
                            /* 1420 */
                            while (newId == 0) {
                                /* 1421 */
                                StructItemOption pot = pots.get(Randomizer.nextInt(pots.size()));
                                /* 1422 */
                                if (pot != null) {
                                    /* 1423 */
                                    newId = pot.opID;

                                }

                            }
                            /* 1426 */
                            int newGrade = ItemConstants.getNebuliteGrade(newId);
                            /* 1427 */
                            if (newGrade != -1 && newGrade > grade && newGrade > 2) {
                                /* 1428 */
                                Item nItem = new Item(newId, (short) 0, (short) 1, (short) 0);
                                /* 1429 */
                                WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.getGachaponMega(chr.getName(), " : 使用星岩魔方升级了星岩获得{" + ii.getName(newId) + "}！大家一起恭喜他（她）吧！！！！", nItem, 3, c.getChannel()));

                            }
                            /* 1431 */
                            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.SETUP, item1.getPosition(), (short) 1, false);
                            /* 1432 */
                            MapleInventoryManipulator.addById(c, newId, (short) 1, "Upgraded from alien cube on " + DateUtil.getCurrentDate());
                            /* 1433 */
                            MapleInventoryManipulator.addById(c, 2430760, (short) 1, "Alien Cube on " + DateUtil.getCurrentDate());
                            /* 1434 */
                            c.announce(MaplePacketCreator.getShowItemGain(newId, (short) 1, true));
                            /* 1435 */
                            chr.getMap().broadcastMessage(InventoryPacket.showNebuliteEffect(chr.getId(), true, "成功交换了星岩。"));
                            /* 1436 */
                            c.announce(MaplePacketCreator.craftMessage("你得到了" + ii.getName(newId)));
                            /* 1437 */
                            used = true;
                            break;

                        }
                        /* 1439 */
                        chr.dropMessage(5, "重置的道具失败.");


                        break;

                    }
                    /* 1443 */
                    chr.dropMessage(5, "您的背包空间不足.");


                    break;

                }
                /* 1447 */
                if (itemId == 5750001) {
                    /* 1448 */
                    if (chr.getLevel() < 10) {
                        /* 1449 */
                        chr.dropMessage(1, "使用这个道具需要等级达到10级.");

                        break;

                    }
                    /* 1452 */
                    Item item1 = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) slea.readInt());
                    /* 1453 */
                    if (item1 != null) {
                        /* 1454 */
                        Equip eq = (Equip) item1;
                        /* 1455 */
                        int sockItem = eq.getSocket1();
                        /* 1456 */
                        if (sockItem > 0 && ii.itemExists(sockItem)) {
                            /* 1457 */
                            eq.setSocket1(0);
                            /* 1458 */
                            chr.forceUpdateItem(item1);
                            /* 1459 */
                            MapleInventoryManipulator.addById(c, sockItem, (short) 1, "摘取星岩: " + DateUtil.getCurrentDate());
                            /* 1460 */
                            MapleInventoryManipulator.addById(c, 2430691, (short) 1, "Alien Cube on " + DateUtil.getCurrentDate());
                            /* 1461 */
                            chr.getMap().broadcastMessage(InventoryPacket.showNebuliteEffect(chr.getId(), true, "成功清空了插槽。"));
                            /* 1462 */
                            used = true;
                            break;

                        }
                        /* 1464 */
                        chr.dropMessage(5, "该道具不具有星岩属性.");


                        break;

                    }
                    /* 1468 */
                    chr.dropMessage(5, "This item's nebulite cannot be removed.");

                }

                break;





            case 577:
                /* 1476 */
                if (JobConstants.is龙的传人(chr.getJob()) && chr.getCoreAura() != null) {
                    /* 1477 */
                    if (itemId == 5770000) {
                        /* 1478 */
                        chr.getCoreAura().setExpiration(chr.getCoreAura().getExpiration() + -1702967296L);
                        /* 1479 */
                        used = true;
                        /* 1480 */
                    } else if (itemId == 5771001) {
                        /* 1481 */
                        chr.getCoreAura().randomCoreAura(1);
                        /* 1482 */
                        used = true;
                        /* 1483 */
                    } else if (itemId == 5771002) {
                        /* 1484 */
                        chr.getCoreAura().randomCoreAura(2);
                        /* 1485 */
                        used = true;
                        /* 1486 */
                    } else if (itemId == 5771003) {
                        /* 1487 */
                        chr.getCoreAura().randomCoreAura(3);
                        /* 1488 */
                        used = true;
                        /* 1489 */
                    } else if (itemId == 5771004) {
                        /* 1490 */
                        chr.getCoreAura().randomCoreAura(4);
                        /* 1491 */
                        used = true;

                    } else {
                        /* 1493 */
                        chr.dropMessage(1, "该道具暂时无法使用。");

                    }
                    /* 1495 */
                    if (used)
                        /* 1496 */ chr.updataCoreAura();

                    break;

                }
                /* 1499 */
                chr.dropMessage(1, "只有龙的传人职业可以使用。");

                break;



            case 579:
                /* 1504 */
                if (itemId == 5790000) {
                    /* 1505 */
                    int slots = c.getAccCardSlots();
                    /* 1506 */
                    if (c.gainAccCardSlot()) {
                        /* 1507 */
                        chr.dropMessage(1, "卡牌扩充成功，当前栏位: " + (slots + 1));
                        /* 1508 */
                        used = true;
                        break;

                    }
                    /* 1510 */
                    chr.dropMessage(1, "卡牌扩充失败，栏位已超过上限。");

                    break;

                }
                /* 1513 */
                chr.dropMessage(1, "该道具无法使用.");

                break;



            case 580:
                /* 1518 */
                if (JobConstants.is爆莉萌天使(chr.getJob())) {
                    /* 1519 */
                    int newLongcoat = 1051294 + itemId % 10;
                    /* 1520 */
                    used = true;
                    /* 1521 */
                    chr.setKeyValue("Longcoat", String.valueOf(newLongcoat));
                    /* 1522 */
                    chr.send(MaplePacketCreator.DressUpInfoModified(chr));

                    break;

                }
                /* 1525 */
                chr.dropMessage(1, "该道具只有爆莉萌天使可以使用。");

                break;


            case 584:
                /* 1529 */
                rewardItemId = 0;
                /* 1530 */
                needItemId = 0;
                /* 1531 */
                needItemIds = new int[]{4310233};
                /* 1532 */
                switch (itemId) {

                    case 5840007:
                        /* 1534 */
                        randItemId = Randomizer.nextInt(5000) + 3010000;
                        /* 1535 */
                        while (ii.getName(randItemId) == null) {
                            /* 1536 */
                            randItemId = Randomizer.nextInt(5000) + 3010000;

                        }
                        /* 1538 */
                        needItemId = needItemIds[Randomizer.nextInt(needItemIds.length)];
                        /* 1539 */
                        if (chr.getInventory(MapleInventoryType.SETUP).getNumFreeSlot() >= 2 && chr.canHold(needItemId)) {
                            /* 1540 */
                            used = true;
                            /* 1541 */
                            rewardItemId = randItemId;
                            /* 1542 */
                            chr.removeItem(4009440, 1);

                            break;

                        }
                        /* 1545 */
                        needItemId = 0;
                        /* 1546 */
                        c.getPlayer().dropMessage(5, "背包空间不足。");

                        break;


                    case 5840006:
                        /* 1550 */
                        arrayList = new ArrayList<>();
                        /* 1551 */
                        arrayList.addAll(ii.getDamageSkinBox().keySet());
                        /* 1552 */
                        needItemId = needItemIds[Randomizer.nextInt(needItemIds.length)];
                        /* 1553 */
                        j = ((Integer) arrayList.get(Randomizer.nextInt(arrayList.size()))).intValue();
                        /* 1554 */
                        if (chr.getInventory(MapleInventoryType.USE).getNumFreeSlot() >= 2 && chr.canHold(needItemId)) {
                            /* 1555 */
                            used = true;
                            /* 1556 */
                            rewardItemId = j;
                            /* 1557 */
                            chr.removeItem(4009440, 1);

                            break;

                        }
                        /* 1560 */
                        needItemId = 0;
                        /* 1561 */
                        c.getPlayer().dropMessage(5, "背包空间不足。");

                        break;


                    case 5840004:
                        /* 1565 */
                        if (chr.getSpace(2) >= 3) {
                            /* 1566 */
                            InventoryHandler.UseFamiliarCard(chr);
                            /* 1567 */
                            used = true;

                            break;

                        }
                        /* 1570 */
                        chr.dropMessage(1, "请确认消耗窗口有3个空栏!");

                        break;

                }
                /* 1573 */
                if (rewardItemId > 0) {
                    /* 1574 */
                    c.announce(MaplePacketCreator.getPeanutResult(rewardItemId, (short) 1, itemId, slot, needItemId, (short) 1));
                    /* 1575 */
                    MapleInventoryManipulator.addById(c, rewardItemId, (short) 1, ii.getName(itemId) + " 在 " + DateUtil.getCurrentDate());
                    /* 1576 */
                    if (needItemId > 0) {
                        /* 1577 */
                        MapleInventoryManipulator.addById(c, needItemId, (short) 1, ii.getName(itemId) + " 在 " + DateUtil.getCurrentDate());

                    }

                }

                break;




            default:
                /* 1585 */
                log.warn("使用未处理的商城道具 : " + itemId + " 封包：" + slea.toString(true));

                break;

        }
        /* 1588 */
        if (itemType == 506) ;


        /* 1591 */
        if (used) {
            /* 1592 */
            MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.CASH, slot, (short) 1, false, true);

        }
        /* 1594 */
        c.announce(MaplePacketCreator.enableActions());
        /* 1595 */
        if (cc) {
            /* 1596 */
            if (!chr.isAlive() || chr.getEventInstance() != null || FieldLimitType.ChannelSwitch.check(chr.getMap().getFieldLimit())) {
                /* 1597 */
                chr.dropMessage(1, "刷新人物数据失败.");

                return;

            }
            /* 1600 */
            chr.dropMessage(5, "正在刷新人数据.请等待...");
            /* 1601 */
            chr.fakeRelog();
            /* 1602 */
            if (chr.getScrolledPosition() != 0) {
                /* 1603 */
                c.announce(MaplePacketCreator.pamSongUI());

            }

        }
    }




    private static boolean getIncubatedItems(MapleClient c, int itemId, short slot) {
        /* 1609 */
        if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNumFreeSlot() < 2 || c.getPlayer().getInventory(MapleInventoryType.USE).getNumFreeSlot() < 2 || c.getPlayer().getInventory(MapleInventoryType.SETUP).getNumFreeSlot() < 2) {
            /* 1610 */
            c.getPlayer().dropMessage(5, "请确保你有足够的背包空间.");
            /* 1611 */
            return false;

        }
        /* 1613 */
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        /* 1614 */
        int id1 = RandomRewards.getPeanutReward(), id2 = RandomRewards.getPeanutReward();
        /* 1615 */
        while (!ii.itemExists(id1)) {
            /* 1616 */
            id1 = RandomRewards.getPeanutReward();

        }
        /* 1618 */
        while (!ii.itemExists(id2)) {
            /* 1619 */
            id2 = RandomRewards.getPeanutReward();

        }
        /* 1621 */
        c.announce(MaplePacketCreator.getPeanutResult(id1, (short) 1, itemId, slot, id2, (short) 1));
        /* 1622 */
        MapleInventoryManipulator.addById(c, id1, (short) 1, ii.getName(itemId) + " 在 " + DateUtil.getCurrentDate());
        /* 1623 */
        MapleInventoryManipulator.addById(c, id2, (short) 1, ii.getName(itemId) + " 在 " + DateUtil.getCurrentDate());
        /* 1624 */
        return true;

    }



    public static void TapJoyResponse(LittleEndianAccessor lea, MapleCharacter player) {
        /* 1628 */
        int slot = lea.readInt();
        /* 1629 */
        int itemId = lea.readInt();

        /* 1631 */
        if (player.getItemQuantity(itemId) > 0) {
            /* 1632 */
            player.send(InventoryPacket.showTapJoyInfo(slot, itemId));

        } else {
            /* 1634 */
            player.sendEnableActions();

        }

    }



    public static void TapJoyDone(LittleEndianAccessor lea, MapleCharacter player) {
        /* 1639 */
        int rank = lea.readInt();
        /* 1640 */
        int slot = lea.readInt();
        /* 1641 */
        int itemid = lea.readInt();
        /* 1642 */
        int hammerid = (rank < 2) ? (5840000 + rank + 1) : 0;
        /* 1643 */
        List<Integer> mods = ItemConstants.TapJoyReward.getRewardList(rank);
        /* 1644 */
        Collections.shuffle(mods);
        /* 1645 */
        int rewardItemId = ((Integer) mods.get(Randomizer.nextInt(mods.size()))).intValue();
        /* 1646 */
        int intValue3 = (rank < 2) ? (itemid + 1) : 0;
        /* 1647 */
        Item item = player.getInventory(MapleInventoryType.ETC).getItem((short) slot);
        /* 1648 */
        int mode = 3;
        /* 1649 */
        int nextBoxSlot = 0;
        /* 1650 */
        if (!player.haveItem(5840000 + rank, 1) || player.getInventory(MapleInventoryType.EQUIP).isFull() || player.getInventory(MapleInventoryType.USE).isFull() || player.getInventory(MapleInventoryType.SETUP).isFull() || player.getInventory(MapleInventoryType.ETC).isFull() || player.getInventory(MapleInventoryType.CASH).isFull()) {
            /* 1651 */
            mode = 4;
            /* 1652 */
        } else if (item != null) {
            /* 1653 */
            short amount = 1;
            /* 1654 */
            player.removeItem(itemid, 1);
            /* 1655 */
            player.removeItem(5840000 + rank, 1);
            /* 1656 */
            ArrayList<ModifyInventory> list = new ArrayList<>();
            /* 1657 */
            if (intValue3 <= 0) {
                /* 1658 */
                mode = 0;

            } else {
                /* 1660 */
                mode = 1;
                /* 1661 */
                nextBoxSlot = MapleInventoryManipulator.addId(player.getClient(), itemid + 1, (short) 1, "", "敲敲乐下一阶段获得！");

            }
            /* 1663 */
            player.gainItem(rewardItemId, 1, "敲敲乐第" + rank + '\001' + "阶段获得");
            /* 1664 */
            player.send(InventoryPacket.showTapJoy(rewardItemId));
            /* 1665 */
            player.send(EffectPacket.getShowItemGain(rewardItemId, (short) 1, true));
            /* 1666 */
            player.send(InventoryPacket.modifyInventory(true, list, player));

        }
        /* 1668 */
        player.send(InventoryPacket.showTapJoyDone(mode, itemid, intValue3, nextBoxSlot, hammerid));

    }



    public static void TapJoyNextStage(LittleEndianAccessor lea, MapleCharacter player) {
        /* 1672 */
        int int1 = lea.readInt();
        /* 1673 */
        int int2 = lea.readInt();
        /* 1674 */
        int itemid = lea.readInt();
        /* 1675 */
        byte byte1 = lea.readByte();
        /* 1676 */
        int intValue = ((Integer) ItemConstants.TapJoyReward.getItemIdAndSN(ItemConstants.TapJoyReward.getSN(itemid).intValue() + 1).getLeft()).intValue();
        /* 1677 */
        int n = 8;
        /* 1678 */
        Item item = player.getInventory(MapleInventoryType.CASH).getItem((short) int2);
        /* 1679 */
        ArrayList<ModifyInventory> mods = new ArrayList<>();
        /* 1680 */
        if (item != null && player.modifyCSPoints(byte1, -(int1 + 1) * 350, false)) {
            /* 1681 */
            if (intValue <= 0) {
                /* 1682 */
                player.getInventory(ItemConstants.getInventoryType(item.getItemId())).removeItem(item.getPosition(), (short) 1, false);
                /* 1683 */
                mods.add(new ModifyInventory(1, item));
                /* 1684 */
                mods.add(new ModifyInventory(3, item));

            } else {
                /* 1686 */
                n = 7;
                /* 1687 */
                item.setItemId(intValue);
                /* 1688 */
                mods.add(new ModifyInventory(0, item));

            }
            /* 1690 */
            player.send(InventoryPacket.modifyInventory(true, mods, player));
            /* 1691 */
            player.send(InventoryPacket.showTapJoy(0));

        }
        /* 1693 */
        player.send(InventoryPacket.showTapJoyNextStage(player, n, int2, intValue, byte1));

    }

}


/* Location:              C:\PGX\Server.jar!\handling\channel\handler\UseCashItemHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */